<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit%>
<% Response.Expires=0 %>
<%
dim aa, bb1, bb2,bb3, cc, name
aa=Request.ServerVariables("LOGON_USER")
cc=Trim(Request.Querystring("AN"))
if len(cc)=0 THEN
cc="!"& aa
cc=right(cc,24)
end if

if instr(1,aa, cc,1)=0 THEN
response.clear
response.end
end if

aa=Request.ServerVariables("HTTP_USER_AGENT")
bb1="Indy"
bb2="idealer.gate"
bb3="moneyps.gate"
if (instr(1,aa, bb1,1)=0) and (instr(1,aa, bb2,1)=0) and (instr(1,aa, bb3,1)=0) THEN

'Response.write "<P align=center><TABLE border=2 cellpadding=6 bgcolor=#e0f0d0><TR><TD><B>Server Variables</B></TD><TD><B>Value</B></TD></TR>"
'For Each name In Request.ServerVariables
'IF (name<>"ALL_HTTP") AND  (name<>"ALL_RAW")  THEN 
'Response.write "<TR><TD>" &name&"</TD><TD>"&Request.ServerVariables(name)&"&nbsp;</TD></TR>"
'END IF
'Next 
'Response.write "</TABLE>"

'response.write aa
'response.write "Hello"
'response.write Request.Querystring
response.clear
response.end
end if
%>
<!--METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library" TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}"-->
<%
dim Node, Sum, PA, CN, DTA, Ph, Ma, ChargeOFF, Ext, BS,OW
Node=request("Node")
if isEmpty(Node) then Node="_P"
Sum=request("Sum")
if isEmpty(Sum) then Sum="0"
ChargeOFF=request("ChargeOFF")
if isEmpty(ChargeOFF) then ChargeOFF="0"
Ma=request("Ma")
if isEmpty(Ma) then Ma="0"
CN=request("CN")
if isEmpty(CN) then CN=""

Ow=request("Ow")
if isEmpty(Ow) then Ow=""

Ext=left(request("Ext"),300)
if isEmpty(Ext) then Ext=""

PA=request("PA")
if isEmpty(PA) then PA=""

if len(PA)>36 then 	
	Ext=Ext+" "+PA
	PA=left(PA,36)
	end if


if Request.Querystring("Cd")="PMB" then  
	if not isEmpty(request("Ph2")) then
		Ext=request("Ph2")
	end if
end if
DTA=request("DTA")
if isEmpty(DTA) then DTA=""
Ph=request("Ph")
if isEmpty(Ph) then Ph=""

BS=request("BS")
if isEmpty(BS) then BS=0


	Dim cnn
	Dim connStr
	dim cmd
	dim R
	Set cnn=Server.CreateObject("ADODB.Connection")
    Set cmd=Server.CreateObject("ADODB.Command")
%>
<!-- #INCLUDE FILE="Connection.inc" -->
<%
''''	connStr="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=Test;Password=Test;Initial Catalog=SMS"&Node&";Data Source=EM-HOME"
	cnn.open connStr
	Set cmd.ActiveConnection = cnn
	cmd.CommandType=adCmdStoredProc
	cmd.CommandText = "sp_AutomatPayment"

	Cmd.Parameters.Append Cmd.CreateParameter("@Return_Value", adInteger, adParamReturnValue)
	Cmd.Parameters.Append Cmd.CreateParameter("@AutomatNumber", adVarChar, adParamInput,24)
	Cmd.Parameters.Append Cmd.CreateParameter("@Phone", adVarChar, adParamInput,20)
	Cmd.Parameters.Append Cmd.CreateParameter("@Sum", adVarChar, adParamInput,10)
	Cmd.Parameters.Append Cmd.CreateParameter("@Margin", adVarChar, adParamInput,10)
	Cmd.Parameters.Append Cmd.CreateParameter("@ChargeOFF", adVarChar, adParamInput,10)
	Cmd.Parameters.Append Cmd.CreateParameter("@Code", adVarChar, adParamInput,16)
	Cmd.Parameters.Append Cmd.CreateParameter("@PA", adVarChar, adParamInput,36)
	Cmd.Parameters.Append Cmd.CreateParameter("@DEMOPayment", adInteger, adParamInput)
	Cmd.Parameters.Append Cmd.CreateParameter("@CN", adVarChar, adParamInput,160)
	Cmd.Parameters.Append Cmd.CreateParameter("@Owner", adVarChar, adParamInput,20)
	Cmd.Parameters.Append Cmd.CreateParameter("@Ext", adVarChar, adParamInput,300)
	Cmd.Parameters.Append Cmd.CreateParameter("@DTA", adVarChar, adParamInput,20)
	Cmd.Parameters.Append Cmd.CreateParameter("@BS", adDouble, adParamInput)
	Cmd.Parameters.Append Cmd.CreateParameter("@id", adInteger, adParamOutput)
	Cmd.Parameters.Append Cmd.CreateParameter("@Res", adInteger, adParamOutput)
	Cmd.Parameters.Append Cmd.CreateParameter("@Result", adVarChar, adParamOutput,160)
	Cmd("@AutomatNumber")=cc
	Cmd("@Phone")=Ph
	Cmd("@Sum")=Sum
	Cmd("@Margin")=Ma
	Cmd("@ChargeOFF")=ChargeOFF
	Cmd("@Code")=Request.Querystring("Cd")
	Cmd("@PA")=PA
	Cmd("@DEMOPayment")=Request.Querystring("De")
	Cmd("@CN")=CN
	Cmd("@Owner")=Ow
	Cmd("@Ext")=Ext
	Cmd("@DTA")=DTA
	Cmd("@BS")=BS
	cmd.execute

If Cmd.Parameters("@Return_value")=0 Then	%>
<Result Res="-1"> 
in process
</Result>
<%
Else
%>
<Result Res="-100"> 
<%=Cmd("@Res")%> / <%=Cmd("@Result")%>
</Result>
<%
End If
	set cmd=nothing
	cnn.close
	set cnn=nothing
%>
